          <?php $errorConclusion = Yii::app()->user->hasFlash('errorConclusion') ? unserialize(Yii::app()->user->getFlash('errorConclusion')) : null ?>
          <!-- START OF MAINCOL -->
          <div class="MainCol AddEbookPage">
          	  <h1>编辑心理测试结论</h1>
              <div class="right"><a href="#add_conclusion" class="Blue_btn" title="add new ebook"><span><?= CHtml::image(Yii::app()->baseUrl.'/images/add_icon.gif', '', array('class' => 'icon')); ?> 添加新结论</span></a>
              </div>
              <span class="NormalFont SmallFont">
                  <?= CHtml::image(Yii::app()->baseUrl.'/images/home_icon.gif', '主页'); ?> > 心理测试管理 > 编辑心理测试主题 > 编辑心理测试结论
               </span><br /><br />
              <div class="Titlebox box"><!-- DON'T DELETE --></div>

                <h4 id="add_dim">“<?php echo htmlspecialchars($topic->topicTitle) ?>”的结论</h4>
              <?php if(Yii::app()->user->hasFlash('successMessage')) : ?>
              <div class="SuccessfulBox Smallbox">
                <span class="Successful"> <?php echo Yii::app()->user->getFlash('successMessage'); ?></span>
              </div>
              <?php endif; ?>

			<?php $i = 0 ?>
			<?php foreach($conclusions as $conclusion) : ?>
			<?php $i++ ?>
              <div class="Smallbox"><label>结论序号</label>
                  <?php echo $conclusion->conclusionOrder == 0 ? '通用结论' : $conclusion->conclusionOrder ?>
                  <?php echo CHtml::link('&nbsp;', array('/admin/psytest/deleteconclusion', 'id' => $conclusion->conclusionId), array('style' => 'float: right;', 'class' => 'Delete', 'confirm' => '确定要删除该结论吗？')) ?>
              </div>

            <?php if($conclusion->isNeedFormula()) : ?>
              <div class="Smallbox"><label>公式</label>
              	<span class="conclusion-formula" id="conclusion_formula_<?php echo $conclusion->conclusionId ?>"><?php echo $conclusion->formula; ?></span>
              </div>
              <?php endif ?>
              
              <div class="Smallbox"><label>结论概括</label>
              	<span class="conclusion-sum" id="conclusion_sum_<?php echo $conclusion->conclusionId ?>"><?php echo $conclusion->conclusionSum != '' ? $conclusion->conclusionSum : '&nbsp;'; ?></span>
              </div>

              <div class="Smallbox"><label>结论描述</label>
              	<span class="conclusion-descr" id="conclusion_descr_<?php echo $conclusion->conclusionId ?>"><?php echo $conclusion->conclusionDescr; ?></span>
              </div>
              
              <div class="Smallbox"><label>&nbsp;</label>
              	<span class=""><a href="<?php echo CHtml::normalizeUrl(array('/admin/psytest/editconclusion', 'id' => $conclusion->conclusionId)) ?>">编辑</a></span>
              </div>

              <div class="Smallbox"><label>&nbsp;</label>
              	<span class="">&nbsp;</span>
              </div>
            <?php endforeach ?>
                <hr />
                <h3 id="add_conclusion">添加新结论</h3>
	            <?php if($errorConclusion !== null) : ?>
	            <?php echo CHtml::errorSummary($errorConclusion) ?>
	            <?php endif ?>

              <?php echo CHtml::form(array('/admin/psytest/addconclusion')); $_conclusion->topicId = $topic->topicId; $_conclusion->updateScenario() ?>
              <?php echo CHtml::activeHiddenField($_conclusion, 'topicId') ?>

                <?php if($topic->getTypeCatalog() == 'mark' && count($topic->dimens) > 0) : ?>
              <div class="Smallbox"><label>维度置位符</label>
              <table>
              <?php foreach($topic->dimens as $dim) : ?>
                <tr><td><?php echo $dim->dimensDescr ?>：</td><td><?php echo $dim->getReplacer() ?></td></tr>
              <?php endforeach ?>
              <?php foreach($topic->secDims as $secDim) : ?>
              	<tr><td>*<?php echo $secDim->dimDescr ?>：</td><td><?php echo $secDim->getReplacer() ?></td></tr>
              <?php endforeach ?>
            </table>
              </div>
              <?php if($topic->hasSecDim) : ?><div class="Smallbox"><label>&nbsp;</label>（带“*”号的为二次维度的置位符）</div><?php endif ?>
              <?php endif ?>

              <?php if($topic->generalConclusion === null) : ?>
              <div class="Smallbox"><label for="is_general_conclusion">是否为通用结论</label>
                    <input type="checkbox" name="isGeneralConclusion" id="is_general_conclusion" /> (每个测试主题只能有一个通用结论)
              </div>
              <?php endif ?>

              <div class="Smallbox"><label>结论序号<span class="Red">*</span></label>
                  <?php echo CHtml::activeTextfield($_conclusion, 'conclusionOrder', array('class' => 'TxtInput', 'style' => 'width: 48px')) ?>
              </div>

            <?php if($_conclusion->isNeedFormula()) : ?>
                <div class="Smallbox"><label>公式<span class="Red">*</span></label>
                  <?php echo CHtml::activeTextfield($_conclusion, 'formula', array('class' => 'TxtInput', 'style' => 'width: 340px')) ?>
              </div>
              <?php endif ?>

                <div class="Smallbox"><label>结论概括<span class="Red">*</span></label>
                  <?php echo CHtml::activeTextfield($_conclusion, 'conclusionSum', array('class' => 'TxtInput', 'style' => 'width: 340px')) ?>
              </div>

				<div class="Smallbox"><label>结论描述<span class="Red">*</span></label>
                <?php /*$this->widget('application.extensions.fckeditor.FCKEditorWidget',array(
                    "model"=>$_conclusion,				# Data-Model
                    "attribute"=>'conclusionDescr',			# Attribute in the Data-Model
                    "height"=>'300px',
                    "width"=>'100%',
                    "toolbarSet"=>'Default', 			# EXISTING(!) Toolbar (see: fckeditor.js)
                    "fckeditor"=>Yii::app()->basePath."/../assets/fckeditor/fckeditor.php",
                                                    # Path to fckeditor.php
                    "fckBasePath"=>Yii::app()->baseUrl."/assets/fckeditor/",
                                                    # Realtive Path to the Editor (from Web-Root)
                    "config" => array("EditorAreaCSS"=>Yii::app()->baseUrl.'/css/common.css',),
                                                    # Additional Parameter (Can't configure a Toolbar dynamicly)
                ) ); */?>
                <?php echo CHtml::activeTextarea($_conclusion, 'conclusionDescr', array('style' => 'height: 180px')); ?>
              </div>
              <div class="Smallbox btnBox"><label>&nbsp;</label>
              <?= CHtml::submitButton('提交'); ?>
              </div>
              <?php echo CHtml::endForm() ?>
              <div class="Smallbox btnBox"><label>&nbsp;</label>
              <?= CHtml::link('返回', array('admin/psytest/edittopic', 'id' => $_conclusion->topicId)); ?>
              </div>
          </div>
          <!-- END OF MAINCOL -->
          <script type="text/javascript">
          $(document).ready(function() {
                $('#is_general_conclusion').change(function() {
                    if($(this).attr('checked') == true)  {
                        $('#TestConclusions_formula').parent('div.Smallbox').hide();
                        $('#TestConclusions_conclusionOrder').parent('div.Smallbox').hide();
                    } else {
                        $('#TestConclusions_formula').parent('div.Smallbox').show();
                        $('#TestConclusions_conclusionOrder').parent('div.Smallbox').show();
                    }
                    
                });  
            });
          </script>
